package com.itchen.hospital.controller;

import com.github.pagehelper.PageInfo;
import com.itchen.hospital.common.Result;
import com.itchen.hospital.pojo.Params;
import com.itchen.hospital.pojo.Hospital;
import com.itchen.hospital.service.HospitalService;
import com.itchen.hospital.service.HospitalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/Hospital")
@Tag(name = "住院登记接口")
@RequiredArgsConstructor
public class HospitalController {

    private final HospitalService hospitalService;

    @GetMapping("/findBySearch")
    @Operation(summary = "条件查询")
    public Result findBySearch(Params params) {
        PageInfo<Hospital> list = hospitalService.search(params);
        return Result.success(list);
    }

    @GetMapping("/update")
    @Operation(summary = "医嘱")
    public Result update(@RequestParam Map<String, String> map) {
        hospitalService.update(map);
        return Result.success();
    }

    //根据id回显
    @GetMapping("/findById")
    @Operation(summary = "根据id回显")
    public Result findById(Integer id) {
        Hospital patientAttendance = hospitalService.findById(id);
        return Result.success(patientAttendance);
    }
}
